#include "stdafx.h"
#include "Array2D.h"

//-------------------------------------------------------------------------
// constructors
//-------------------------------------------------------------------------

CArray2D::CArray2D(unsigned int m, unsigned int n)
{
	m_nDim1 = m;
	m_nDim2 = n;

	// Dimension 1

	m_fArray = new float * [m_nDim1];

	// Dimension 2

	for (unsigned int i=0; i<m_nDim1; i++)
	{
		m_fArray[i] = new float[m_nDim2];
		memset(&m_fArray[i][0], 0, m_nDim2 * sizeof(float)); // init to zero
	}
};

//-------------------------------------------------------------------------
// destructors
//-------------------------------------------------------------------------

CArray2D::~CArray2D()
{
	// Dimension 2

	for (unsigned int i=0; i<m_nDim1; i++)
	{
		delete [] m_fArray[i];
		m_fArray[i] = 0;
	}

	// Dimension 1

	delete [] m_fArray;
	m_fArray = 0;
};
